const  body=document.body;
const menuLinks=document.querySelectorAll(".admin-menu a");
const collapseBtn=document.querySelector(".admin-menu .collapse-btn");
const toggleMobileMenu=document.querySelector(".toggle-mob-menu");
const collapsedClass="collapsed";

collapseBtn.addEventListener("click",function () {
    this.getAttribute("aria-expanded") === "true"
    ? this.setAttribute("aria-expend","false")
    : this.setAttribute("aria-expanded","true");
    this.getAttribute("aria-label") === "collapse menu"
    ? this.setAttribute("aria-label","expand menu")
    : this.setAttribute("aria-label","collapse menu");
    body.classList.toggle(collapsedClass)
});

toggleMobileMenu.addEventListener("click",function () {
    this.getAttribute("aria-expanded")==="true"
    ?this.setAttribute("aria-expended","false")
    : this.setAttribute("aria-expended","true");
    this.getAttribute("aria-label") === "true"
    ? this.setAttribute("aria-label","close menu")
    : this.setAttribute("aria-label","open menu");
    body.classList.toggle("mob-menu-opened");
});

for(const link of menuLinks){
    link.addEventListener("mouseenter",function () {
        body.classList.contains(collapsedClass) &&
            window.matchMedia("(min-width:768px)").matches
            ? this.setAttribute("title",this.textContent.trim())
            : this.removeAttribute("title")
    })
}
